package com.ruoyi.adapayDrawcash.controller;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.constant.DicConstants;
import com.ruoyi.adapayDrawcash.domain.AdapayDrawcash;
import com.ruoyi.adapayDrawcash.service.IAdapayDrawcashService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提现记录Controller
 *
 * @author ch
 * @date 2022-02-28
 */
@RestController
@RequestMapping("/adapayDrawcash/adapayDrawcash")
public class AdapayDrawcashController extends BaseController
{
    @Autowired
    private IAdapayDrawcashService adapayDrawcashService;

    /**
     * 查询提现记录列表
     */
    @PreAuthorize("@ss.hasPermi('adapayDrawcash:adapayDrawcash:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdapayDrawcash adapayDrawcash)
    {
        startPage();
        List<AdapayDrawcash> list = adapayDrawcashService.selectAdapayDrawcashList(adapayDrawcash);
        return getDataTable(list);
    }

    /**
     * 导出提现记录列表
     */
    @PreAuthorize("@ss.hasPermi('adapayDrawcash:adapayDrawcash:export')")
    @Log(title = "提现记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdapayDrawcash adapayDrawcash)
    {
        List<AdapayDrawcash> list = adapayDrawcashService.selectAdapayDrawcashList(adapayDrawcash);
        ExcelUtil<AdapayDrawcash> util = new ExcelUtil<AdapayDrawcash>(AdapayDrawcash.class);
        return util.exportExcel(list, "提现记录数据");
    }

    /**
     * 获取提现记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('adapayDrawcash:adapayDrawcash:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(adapayDrawcashService.selectAdapayDrawcashById(id));
    }

    /**
     * 新增提现记录
     */
    @PreAuthorize("@ss.hasPermi('adapayDrawcash:adapayDrawcash:add')")
    @Log(title = "提现记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdapayDrawcash adapayDrawcash)
    {
        return toAjax(adapayDrawcashService.insertAdapayDrawcash(adapayDrawcash));
    }

    /**
     * 修改提现记录
     */
    @PreAuthorize("@ss.hasPermi('adapayDrawcash:adapayDrawcash:edit')")
    @Log(title = "提现记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdapayDrawcash adapayDrawcash)
    {
        adapayDrawcash.setUpdateType(DicConstants.BUSINESS_Manager.getCode());
        return toAjax(adapayDrawcashService.updateAdapayDrawcash(adapayDrawcash));
    }

    /**
     * 删除提现记录
     */
    @PreAuthorize("@ss.hasPermi('adapayDrawcash:adapayDrawcash:remove')")
    @Log(title = "提现记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adapayDrawcashService.logicDeleteAdapayDrawcash(ids,DicConstants.BUSINESS_Manager.getCode(),SecurityUtils.getUserId()));
    }
}
